package utils;

import com.google.gdata.data.appsforyourdomain.provisioning.UserEntry;
import sample.appsforyourdomain.AppsForYourDomainClient;

public class UsersInfo {

	public static String getFullName(String EmailID) {

		String strDomain = System.getProperty("DOMAIN");
		String strUserName = System.getProperty("ADMIN_USERNAME");
		String strPwd = System.getProperty("ADMIN_PWD");
		String strUser_ID = EmailID.substring(0, EmailID.indexOf("@"));
		String strFull_Name = "";
		UserEntry entry = null;

		try {

			AppsForYourDomainClient client = new AppsForYourDomainClient(
					strUserName, strPwd, strDomain);
			entry = client.retrieveUser(strUser_ID);
			if (entry != null)
				strFull_Name = entry.getName().getGivenName().toString().trim()
						+ " "
						+ entry.getName().getFamilyName().toString().trim();

		} catch (Exception e) {
			e.printStackTrace();
		}

		return strFull_Name;
	}

}